<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>App更新</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="__LAYUIADMIN__/res/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="__LAYUIADMIN__/res/adminui/dist/css/admin.css" media="all">
</head>

<body>

  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="layui-card">
          <div class="layui-card-header">App更新</div>
          <div class="layui-card-body">
            <div class="layui-form" lay-filter="">
              <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">更新公告</label>
                <div class="layui-input-block">
                  <textarea name="notice" class="layui-textarea" placeholder="更新公告">{$data.notice}</textarea>
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">App版本</label>
                <div class="layui-input-inline">
                  <input type="number" lay-affix="number" name="version" placeholder="App版本" step="0.01"
                    class="layui-input" value="{$data.version}">
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">更新地址</label>
                <div class="layui-input-inline">
                  <input type="text" name="href" value="{$data.href}" placeholder="更新地址" autocomplete="off"
                    class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">强制更新</label>
                <div class="layui-input-block">
                  <input type="checkbox" name="force_upgrade" lay-skin="switch" lay-filter="switchTest" title="开启|关闭"
                    {$data.force_upgrade==1 ? 'checked' : '' }>
                </div>
              </div>
              <div class="layui-form-item">
                <div class="layui-input-block">
                  <button class="layui-btn" lay-submit lay-filter="demo1">确认保存</button>
                </div>
              </div>
            </div>
          </div>

        </div>
      </div>


    </div>
  </div>
  </div>

  <script src="__LAYUI__/layui.js"></script>
  <script>
    layui.use(function () {
      var form = layui.form;
      var layer = layui.layer;
      var laydate = layui.laydate;
      var util = layui.util;
      $ = layui.$;


      // 提交事件
      form.on('submit(demo1)', function (data) {
        var field = data.field; // 获取表单字段值
        field.force_upgrade = field.force_upgrade == 'on' ? 1 : 0
        $.post('/admin/system/update/?conf=sys_upgrade', field, (res) => {
          if (res.code == 200) {
            layer.msg('保存成功')
          } else {
            layer.msg(res.msg)
          }
        })
        return false;
      });

    
    });


  </script>
</body>

</html>